<?

// INCLUDES //
require_once  $_SERVER['DOCUMENT_ROOT']."/../_lib/base/common.php";

// CLASSES //
require_once SITE_ROOT_PATH."/_lib/classes/class.template.php";

// user authentication
user_auth_booking_tracker();

// HEAD
require_once SITE_ROOT_PATH."/_lib/html/admin_head.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.bookings.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.holidays.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.accommodation.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.exchange_rates.php";

// FUNCTION // Show home page ==========================================
function display_home(){	

		$bookings = new bookings();
		$holidays = new holidays();

?>

<h2>Holiday Exclusion Filter</h2>

<h3>Exclude a single holiday</h3>





<p><strong>To remove a holiday from the system</strong> simply enter the Holiday Reference number into the form below</p>
<p><strong>To remove an entire flight from the system</strong> select the &quot;Filter entire flight&quot; option in the form below. This feature should be used when a tour operators flight is no longer available.</p>
<p><strong>Note:</strong> Only filter out holidays where you are 100% certain that the accommodation/flight is unavailable as once set, the filter cannot be undone.</p>

<form action="<? $_SERVER['PHP_SELF']?>" method="get">

<fieldset style="padding: 10px;">

	<input type="hidden" name="action" value="insert" />

	<table class="libra">
		<tr>
			<td width="150">Reference number:</td>
			<td><input type="text" name="holiday_id" value="<?= $_REQUEST['holiday_id'] ?>"></td>
		</tr>
		<tr>
			<td>Filter entire flight:</td>
			<td><input type="checkbox" value="1" name="entire_flight" /></td>
		</tr>
			<td colspan="2" align="center"><input type="submit" value="Submit" class="form_button"></td>

		</tr>
	</table>

</fieldset>

</form>


<?
}
// END FUNCTION =================================================





switch ($_REQUEST['action']){
	default:
		display_home();
	break;
	case "insert";
		$bookings = new bookings();
		$holiday = $bookings->search_holiday_reference($_GET['holiday_id']);
		if($holiday){
			if($_GET['entire_flight']=='1'){
				$a_entire_flight = array("entire_flight"=>"1");
			}
			
			$holiday_details = array_merge($holiday, $a_entire_flight);

			$holidays = new holidays();
			$holidays->insert_hidden_holiday($holiday_details);
			$GLOBALS['msg'] = "Holiday '".$_GET['holiday_id']."' has been excluded from the system ";
			display_home();
		}else{
			$GLOBALS['msg_error'] = "There was no holiday found with the reference '".$_GET['holiday_id']."' ";
			display_home();
		}
	break;
}
	


// Foot
require_once SITE_ROOT_PATH."/_lib/html/admin_foot.php";

?>